<template>

	<view class="cust_bg_five" :style="{
	        '--borcolor': parameter.borColor || '#876d59',
	        '--btnbg': parameter.btnBg || '#684833',
	        '--fontbg': parameter.fontBg || '#d3bf9e',
	        '--contbg': parameter.contBg || '#473425',
	        '--btn_fontBg': parameter.btn_fontBg || '#d3bf9e',
	        '--price_color': parameter.price_color || '#e55c27',
	        '--color': '#F34D4E',
	        '--price': '#E55C27',
	      }">
		<view class="cust_bg_five_item" v-for="(item, index) in dataList" :key="index" @click="goProdDetail(item)">
			<view class="cust_bg_five_item_top">
				<view class="cust_bg_five_item_t_img">
					<u-swiper mode='none' :list="imgList(item.img)"></u-swiper>
				</view>
				<view class="cust_bg_five_item_t_content">
					<view class="cust_bg_five_hot">重点推荐</view>
					<view class="cust_bg_five_advantage u-line-2">
						{{item.superiority}}
					</view>
					<view class="cust_bg_five_robbed">
						已抢{{ item.order_count || 0 }}件
					</view>
				</view>
			</view>
			<view class="cust_bg_five_item_bottom">
				<view class="cust_bg_five_item_bottom_name">
					{{
	              item.name
	            }}
				</view>

				<view class="cust_bg_five_item_bottom_box">
					<view class="sww-prod-price">
						<span class="sign">￥</span>
						<span class="price">
							{{ $price(item.price) | priceFmt(false) }}
						</span>
						<span class="sign">
							{{ $price(item.price) | priceFmt(true) }}
						</span>
						<span v-if="item.market_price && item.market_price > 0" class="sww-prod-market-price">
							￥{{ $price(item.market_price) }}
						</span>
					</view>
					<view class="cust_bg_five_item_buy">立即抢购</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		components: {},
		props: {
			parameter: {
				type: Object,
				default: () => {
					return {};
				}
			},
			dataList: {
				type: Array,
				default: []
			}
		},
		computed: {
			imgList(list) {
				return function(list) {
					if (!list) return []
					return list.split(',').reduce((pre, el) => {
						pre.push({
							image: el,
							title: ''
						})
						return pre
					}, [])
				}
			},
		},
		data() {
			return {};
		},
		filters: {
			priceFmt(price, isPoint = false) {
				let [priceInt, pricePoint] = price.split('.');
				return isPoint ? (pricePoint ? '.' + pricePoint : '') : priceInt;
			}
		},

		methods: {
			goProdDetail(item) {
				if (item.type == 2) {
					let currentTime = new Date().getTime();
					if (currentTime > item.end_date) {
						this.$toast({
							title: '活动已结束'
						});
						return;
					}
				}
				this.$toProd({
					...item,
					prodType: 1
				});
			}
		}
	};
</script>

<style scoped lang="scss">
	.cust_bg_five {
		padding: 26rpx;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		flex-direction: column;

		.cust_bg_five_item {
			padding: 22rpx;
			width: 100%;
			background: linear-gradient(#C64A4C, #E4C6C5);
			height: 100%;
			border-radius: 16rpx;
			margin-bottom: 26rpx;
		}

		.cust_bg_five_item_top {
			background-image: url('../../static/icon/proBg.png');
			background-repeat: no-repeat;
			background-size: cover;
			display: flex;
			border-radius: 16rpx;
			overflow: hidden;
			padding: 16rpx;

			.cust_bg_five_item_t_img {
				width: 280rpx;
				border-radius: 20rpx;
				overflow: hidden;
			}

			.cust_bg_five_item_t_content {
				flex: 1;
				margin-left: 10px;
				padding: 60rpx 0 20rpx;

				.cust_bg_five_hot {
					font-size: 32rpx;
				}

				.cust_bg_five_advantage {
					font-size: 24rpx;
					margin: 30rpx 0;
				}

				.cust_bg_five_robbed {
					display: inline-block;
					padding: 6rpx 10rpx;
					background-color: #d5b48a;
					color: #ffffff;
					font-size: 24rpx;
					border-radius: 12rpx;
				}
			}
		}

		.cust_bg_five_item_bottom {
			.cust_bg_five_item_bottom_name {
				overflow: hidden;
				/*超出部分隐藏*/
				white-space: nowrap;
				/*不换行*/
				text-overflow: ellipsis;
				/*超出部分文字以...显示*/
				margin: 30rpx 0 20rpx;
				color: rgba(0, 0, 0, 0.7);
			}

			.cust_bg_five_item_buy {
				padding: 16rpx 20rpx;
				color: #ffffff;
				background-color: #d5b48a;
				border-radius: 16rpx;
				font-size: 24rpx;
			}

			.cust_bg_five_item_bottom_box {
				display: flex;
				justify-content: space-between;

				.sww-prod-price {
					font-weight: 500;
					flex: 1;
					overflow: hidden;
					font-size: 0;

					.sww-prod-market-price,
					.sww-prod-sale {
						font-size: 24rpx;
						margin-left: 12rpx;
						color: #000000;
					}

					.sign {
						color: #000000;
						font-size: 26rpx;
					}

					.price {
						color: #000000;
						font-size: 40rpx;
					}

					.sww-prod-market-price {
						text-decoration: line-through;
					}
				}
			}
		}
	}
</style>
